package io.yunho.yunho.interview.two.java8.lambda;

import java.util.function.Function;

/**
 * @author: Jason
 * @date: 2021/5/7 20:54
 * @description:
 */
public class CurryDemo {
    public static void main(String[] args) {
       Function<Integer,Function<Integer,Integer>> functionFunction = x-> y-> x + y;

        System.out.println(functionFunction.apply(2).apply(3));
        
        Function<Integer,Function<Integer,Function<Integer,Integer>>> fun2 = x-> y-> z-> x + y+z;
        
        int[] nums={2,3,4};
        Function f = fun2;
        for (int i = 0; i < nums.length; i++) {
            if(f instanceof Function){
                Object obj = f.apply(nums[i]);
                if(obj instanceof  Function){
                    f = (Function)obj;
                }else{
                    System.out.println("最终结果："+obj);
                }
            }
        }
        
    }
}
